import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import doc_code from '@dfeidao/atom-mobile/msg/doc-code';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import alert from '@dfeidao/atom-mobile/msgbox/alert';
import toast from '@dfeidao/atom-mobile/msgbox/toast';
import { systemid } from '../atom/config';
export default async function a008(fd: IFeidaoAiMobile, a: {}, args: {
	student_name: string; // 学生姓名
	student_no: string; // 学生编号
	parent_number: string; // 家长编号
	parent_name: string; // 家长名称
}) {
	const alerts = await alert(' ', '                                   确认签退吗?', ['确认                               ', '取消                          ']);
	if (alerts !== 0) {
		return;
	}
	// 签退
	const { result: sign_off_num } = await doc_code(systemid, 'BM0016038', '', 1) as { result: string };
	const user = get(fd, 'params') as {
		teacher_name: string;
		productid: string;
		teacher_no: string;
	};
	const params = {
		sign_off_num,
		sign_off_manner: '个人',
		teacher_no: user.teacher_no,
		teacher_name: user.teacher_name,
		student_no: args.student_no,
		student_name: args.student_name,
		parent_number: args.parent_number,
		parent_name: args.parent_name,
		leave_time: new Date().getTime(),
		productid: user.productid,
		sign_off_status: '1'
	};
	const res = await nodejs<{ code: number }>('app-check-status/s002', {
		params
	});
	if (res.code !== 0) {
		toast({
			type: 'success', // 'danger' | 'success' | 'warning'
			text: '签退成功',
			position: 'top' // 'top' | 'bottom' | 'center'
		});
	} else {
		toast({
			type: 'danger', // 'danger' | 'success' | 'warning'
			text: '签退失败',
			position: 'top' // 'top' | 'bottom' | 'center'
		});
	}
}
